<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('material_contracts', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('project_id');
            $table->unsignedBigInteger('material_id');
            $table->unsignedBigInteger('supplier_id');
            $table->unsignedBigInteger('user_id');
            $table->decimal('price', 10, 2)->default(0);
            $table->integer('tax_rate')->default(0);
            $table->decimal('tax_price', 10, 2)->default(0)->comment('税金');
            $table->string('name', 255)->default('/')->comment('甲方名称');
            $table->integer('contract_type')->default(1)->comment('1材料 2双包 3材料');
            $table->string('tax_id', 50)->nullable()->default('/')->comment('甲方税号');
            $table->string('address', 255)->nullable()->default('/')->comment('甲方地址');
            $table->string('mobile', 20)->nullable()->default('/')->comment('甲方联系电话');
            $table->string('bank', 255)->nullable()->default('/')->comment('甲方开户银行');
            $table->string('bank_number', 255)->nullable()->default('/')->comment('甲方开户好');
            $table->string('bank_account', 50)->nullable()->default('/')->comment('甲方银行账号');
            $table->string('email', 255)->nullable()->default('/')->comment('');
            $table->string('postal_code', 50)->nullable()->default('/')->comment('邮编');

            $table->string('b_name', 255)->default('/')->comment('乙方名称');
            $table->string('b_tax_id', 50)->nullable()->default('/')->comment('乙方税号');
            $table->string('b_address', 255)->nullable()->default('/')->comment('乙方地址');
            $table->string('b_mobile', 20)->nullable()->default('/')->comment('乙方联系电话');
            $table->string('b_bank', 255)->nullable()->default('/')->comment('乙方开户银行');
            $table->string('b_bank_number', 255)->nullable()->default('/')->comment('乙方开户好');
            $table->string('b_bank_account', 50)->nullable()->default('/')->comment('乙方银行账号');
            $table->string('b_email', 255)->nullable()->default('/')->comment('');
            $table->string('b_postal_code', 50)->nullable()->default('/')->comment('邮编');

            $table->string('b_authorize_file')->nullable()->default('')->comment('上传委托代理授权书');
            $table->string('b_business_file')->nullable()->default('')->comment('上传公司营业执照');
            $table->string('b_idcard_file')->nullable()->default('')->comment('上传法人身份证');
            $table->string('b_agent_idcard_file')->nullable()->default('')->comment('上传代理人身份证');
            $table->string('b_legal')->nullable()->default('/')->comment('企业法人');
            $table->string('b_legal_mobile')->nullable()->default('/')->comment('企业法人联系电话');
            $table->string('b_agent')->nullable()->default('/')->comment('代理人');
            $table->string('b_agent_mobile')->nullable()->default('/')->comment('代理人联系电话');
            $table->string('deliver_address')->nullable()->default('/')->comment('交付地点');
            $table->string('receiver')->nullable()->default('/')->comment('签收人');
            $table->integer('sums')->default(0)->comment('材料数量');
            $table->string('unit')->nullable()->comment('材料数量单位');
            $table->decimal('unit_price', 10, 2)->default(0)->comment('材料单价');
            $table->string('variety')->nullable()->default('/')->comment('品种要求');
            $table->string('pay_type')->nullable()->default('/')->comment('付款方式');
            $table->unsignedBigInteger('apply_id')->default(0)->comment('申请人');
            $table->decimal('liquidated_damages', 10, 2)->default(0)->comment('违约金');
            $table->string('approver')->nullable()->default('/')->comment('审批人');
            $table->string('remarks')->nullable()->default('/')->comment('备注');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('material_contracts');
    }
};
